package com.ruoyi.tenant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.tenant.domain.SysAdvice;
import com.ruoyi.tenant.service.ISysAdviceService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.page.TableDataInfo;


@RestController
@RequestMapping("/system/advice")
public class SysAdviceController extends BaseController
{
    @Autowired
    private ISysAdviceService sysAdviceService;

    @PostMapping
    public AjaxResult add(@RequestBody SysAdvice sysAdvice)
    {
        sysAdvice.setTenantid(getLoginUser().getTenantId().toLowerCase());
        sysAdvice.setUsername(getLoginUser().getUsername());
        return toAjax(sysAdviceService.insertSysAdvice(sysAdvice));
    }


    @GetMapping("/list")
    public TableDataInfo list(SysAdvice sysAdvice)
    {
        startPage();
        List<SysAdvice> list = sysAdviceService.selectSysAdviceList(sysAdvice);
        return getDataTable(list);
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysAdviceService.deleteSysAdviceByIds(ids));
    }
}
